package cn.wizzer.app.task.commons.ext.quartz.job;

import cn.wizzer.app.crown.modules.models.constant.CrownRedisConstant;
import cn.wizzer.app.crown.modules.services.order.CrownOrderService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.nutz.integration.jedis.RedisService;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;


/**
 * 定时订单确认
 * @author
 */
@IocBean
public class CrownJobOrderConfirm implements Job {
    @Inject
    @Reference
    private CrownOrderService orderService;

    @Inject
    private RedisService redisService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        // 如果在维护中，return
        String redisLock = redisService.get(CrownRedisConstant.CROWN_MAINTAIN);
        if (Strings.isNotBlank(redisLock)) {
            return;
        }
        orderService.orderConfirm();
    }
}
